package implementor;

import java.sql.SQLException;

import dao.AssignedToDao;
import dbhandelling.Crude;
import dto.AssignedTo;


public class AssignedToImpl extends Crude implements AssignedToDao{

	String className=new AssignedTo().getClass().getName();
	@Override
	public void add(AssignedTo assign) throws SQLException, Exception {
		super.insert(assign);
		
	}

	@Override
	public void update(AssignedTo assign) throws Exception {
		super.update(className, "projectId",assign.getProjectId()+"", "autoIdAssignedTo", assign.getAutoIdAssignedTo()+"");
		super.update(className, "employeeId",assign.getEmployeeId()+"", "autoIdAssignedTo", assign.getAutoIdAssignedTo()+"");
	}

	@Override
	public void delete(AssignedTo assign) throws Exception {
		super.delete(className, "autoIdAssignedTo", assign.getAutoIdAssignedTo()+"");
		
	}

	@Override
	public AssignedTo retreive(String conditionField, String ConditionValue)
			throws Exception {
		AssignedTo a=(AssignedTo) super.retreive(className, conditionField, ConditionValue);
		return a;
	}

	@Override
	public AssignedTo[] retreiveArray(String conditionField,
			String ConditionValue) throws Exception {
		Object[] assignto= super.retreiveArrayOnCondition(className, conditionField, ConditionValue);
		AssignedTo[] s=new AssignedTo[assignto.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(AssignedTo) assignto[i];
		return s;
	}

	@Override
	public AssignedTo[] retreiveAll() throws Exception {
		Object[] assignto= super.retreiveAll(className);
		AssignedTo[] s=new AssignedTo[assignto.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(AssignedTo) assignto[i];
		return s;	
	}

}
